<template>
  <div>
    <!-- 仅企业信息, 不包含规则 -->
    <!-- <div v-if="info.auditStatus === 'Pass' && !isHistory">
      <InfoHead
        :auditStatus="info.baseStatus"
        :auditStatusName="info.baseStatusName"
        :updateDateTime="info.companyBaseOffTime"
        :companyOffReason="info.companyBaseOffReason"
        :isEdit="isEdit"
        @edit="onInfoEdit"
        @revoke="onRevoke('1')"
      />
    </div>-->
    <!-- 所有 -->
    <!-- <div v-else> -->
    <InfoHead
      :auditStatus="info.auditStatus"
      :auditStatusName="info.auditStatusName"
      :updateDateTime="info.updateDateTime"
      :companyOffReason="info.companyOffReason"
      :isEdit="isEdit"
      @edit="onAllEdit"
      @revoke="onRevoke('0')"
    />
    <!-- </div> -->

    <Form>
      <Divider />
      <h4 class="info-title">企业基本信息</h4>
      <Row class="com-form-item">
        <Col span="8">
          <FormItem label="企业名称:">{{ info.companyName }}</FormItem>
        </Col>
        <Col span="8">
          <FormItem label="上级组织:">{{ info.parentName }}</FormItem>
        </Col>
        <Col span="8">
          <FormItem label="证件类型:">{{ info.companyCardTypeName }}</FormItem>
        </Col>
        <Col span="8">
          <FormItem label="证件号码:">{{ info.companyCardNumber }}</FormItem>
        </Col>
        <Col span="8">
          <FormItem label="注册地址:">{{ info.companyAddress }}</FormItem>
        </Col>
        <Col span="8">
          <FormItem label="证件照片:">
            <div class="view-img-box">
              <ViewImg
                v-if="info.companyIdFiles && info.companyIdFiles.length"
                isPreview
                isIcon
                errorMsg="证件照片"
                :fileList="info.companyIdFiles"
              ></ViewImg>
            </div>
          </FormItem>
        </Col>
        <Col span="24">
          <FormItem label="业务范围:">{{ info.businessRange }}</FormItem>
        </Col>
      </Row>

      <Divider />
      <h4 class="info-title">企业服务能力</h4>
      <Row class="com-form-item">
        <Col span="24">
          <FormItem label="服务地区:">{{ info.serviceAreaName }}</FormItem>
        </Col>
        <Col span="24">
          <FormItem label="产业标记:">{{ info.serviceTypeName }}</FormItem>
        </Col>
      </Row>
    </Form>

    <Divider />
    <h4 class="info-title">企业资质</h4>
    <Table :columns="columns" :data="info.companyAptitudeFiles">
      <template slot-scope="{ row }" slot="files">
        <ViewImageList v-if="row.files.length" isViewBtn :echoFile="row.files" />
      </template>
    </Table>
  </div>
</template>

<script>
import InfoHead from './infoHead.vue'

export default {
  name: 'infoPage',
  components: { InfoHead },
  props: {
    info: {
      type: Object,
      default: () => { }
    },
    isEdit: {
      type: Boolean,
      default: false
    },
    isHistory: {
      type: Boolean,
      default: false
    },
  },
  data () {
    return {
      columns: [
        {
          title: "资质名称",
          key: "companyAptitudeName",
        },
        {
          title: "等级",
          key: "lv",
        },
        {
          title: "资质附件",
          slot: "files",
        },
        {
          title: "有效期截止时间",
          key: "validEndDate",
        },
      ],
    }
  },
  methods: {
    // 全部修改
    onAllEdit () {
      this.$router.push({ path: '/createEditCompany', query: { type: 'all' } })
    },
    // 信息修改
    onInfoEdit () {
      this.$router.push({ path: '/createEditCompany', query: { type: 'info' } })
    },
    // 撤销
    onRevoke (companyUpdateType) {
      this.$emit('revoke', companyUpdateType)
    },
  }
}
</script>

<style lang='less' scoped>
.mt-20 {
  margin-top: 20px;
}

.ml-20 {
  margin-left: 20px;
}
.info-title {
  margin: 10px 0;
}
.view-img-box {
  padding-top: 5px;
  margin-bottom: -5px;
}
</style>
